﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ProTrack.Utility
{
    /// <summary>
    /// base64 是一种公开的算法；不是加密算法；只是对字符进行编码
    /// </summary>
    public class Base64Helper
    {
        /// <summary>
        /// 根据字符串 获取base64编码规则
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>
        public static string GetBase64ByString(string content)
        {
            byte [] arr = Encoding.Default.GetBytes(content);
            return Convert.ToBase64String(arr);
        }

        /// <summary>
        /// 根据base64编码规则获取字符串
        /// </summary>
        /// <param name="base64"></param>
        /// <returns></returns>
        public static string GetStringByBase64(string base64)
        {
            byte[] arr = Convert.FromBase64String(base64);
            return Encoding.Default.GetString(arr) ;
        }
    }
}
